

  const promise = new Promise((resolve, reject) => {
    const error = false;
    if (!error) {
    resolve({ name: "John", age: 30 });
    } else {
    reject("出现了问题");
    }
   });
   promise
    .then(user => {
    console.log(user);
    return user.name;
    })
    .then(name => {
    console.log(name);
    return name.length;
    })
    .then(nameLength => {
    console.log(nameLength);
    })
    .catch(error => {
    console.log(error);
    });

   